import axios from '@/libs/api.request'
import { getToken } from '@/libs/util'


class Fence {
  constructor() {
    this.$axios = axios;
  }

  /**
   * 分页查询设备
   * @param param
   * @returns {*}
   */
  queryPage = (param) => {
    return axios.request({
      url: '/admin/fence/query/page/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }

  /**
   * 新增设备
   */
  add = (param) => {
    return axios.request({
      url: '/admin/fence/add/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }

  /**
   * 修改设备
   * @param param
   * @returns {*}
   */
  update = (param) => {
    return axios.request({
      url: '/admin/fence/update/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }

  /**
   * 删除设备
   * @param param
   * @returns {*}
   */
  remove = (param) => {
    return axios.request({
      url: '/admin/fence/delete/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }


  /**
   * 查询部门国栏树查询
   * @param param
   * @returns {AxiosPromise}
   */
  findFenceForOrgTrue=(param)=>{
    let url='/admin/fence/tree/find/for/org'
/*    if (!!param){
      url=url+"?id="+param;
    }*/
    return axios.request({
      url: url,
      method: 'get',
      dataType: 'json',
      headers: {
        'Content-Type': 'text/html; charset=UTF-8',
        'token': getToken()
      },
      params: param
    })
  }

  /**
   * 分页查询围栏报警数据
   * @param param
   * @returns {*}
   */
  alarmQueryPage = (param) => {
    return axios.request({
      url: '/admin/fence/alarm/query/page/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }

}

export default Fence;
